package com.eight.cloud.admin.service;

import com.eight.cloud.admin.entity.PermissionEntity;
import com.eight.cloud.admin.model.dto.PermissionDto;
import com.eight.cloud.mybatisplus.service.IBaseService;
import com.eight.cloud.core.global.model.LoginUser;
import com.eight.cloud.core.global.model.SysPermission;
import com.eight.cloud.core.global.model.UserPermission;
import com.eight.cloud.core.utils.structure.tree.TreeNode;
import com.eight.cloud.openfeign.admin.vo.permission.PermissionDetail;
import com.eight.cloud.openfeign.admin.vo.permission.PermissionTree;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 权限表 服务类
 * </p>
 *
 * @author TXC
 * @since 2024-10-02
 */
public interface IPermissionService extends IBaseService<PermissionEntity> {
    /**
     * 获取权限树
     * @return 权限树
     */
    List<TreeNode<SysPermission>> getPermissionTree(LoginUser loginUser);

    /**
     * 获取用户权限集合
     * @param loginUser 用户信息
     * @return 权限树
     */
    Map<String, UserPermission> getUserPermissionMap(LoginUser loginUser);

    /**
     * 从文件中获取权限树
     */
    void initPermission(PermissionTree permissionTree);

    /**
     * 更新模块权限
     * @param permissionDetails 模块权限
     * @param module 模块
     */
    void updateModulePermission(List<PermissionDetail> permissionDetails, String module);

    /**
     * 查询系统权限
     */
    List<String> getPermissionCodes();

    /**
     * 批量创建权限
     * @param permissionDtoList 权限列表
     * @param module 模块
     */
    void flushPermission(List<PermissionDto> permissionDtoList, String module);

    /**
     * 清理表
     */
    void truncate();

}
